package ink.lovejinhu.leetcode;


import ink.lovejinhu.common.TreeNode;

/**
 * @author jinhu
 * created 2021-05-07 15:40
 */
public class Solution_0100 {
    /**
     * 判断两颗树是否相同
     *
     * @param p
     * @param q
     * @return
     */
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if (p == null && q == null) {
            return true;
        }
        if (p == null && q != null) {
            return false;
        }
        if (p != null && q == null) {
            return false;
        }
        if (p.val== q.val){
            return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
        }else {
            return false;
        }

    }
}
